#!/usr/bin/node

const log = console.log;

const cp = require('child_process');
const cmd = process.argv[2] || 'cat';
const path = require('path');
const filename = path.basename(__filename);
let args = [];

if(process.argv.length > 3){
  args = process.argv.slice(3,process.argv.length);
}else if(process.argv.length === 3 || process.argv.length === 2){
  args.push(filename);
}

log('cmd:',cmd);
log('args:',args);

cp.execFile(cmd,args,(err,data)=>{
  if(err){
    console.error(err.message);
    process.exit(1);
  }
  log(data);
})
